package com.graduate.emos.wx.controller;

import com.graduate.emos.wx.common.util.R;
import com.graduate.emos.wx.controller.form.TestSayHelloForm;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/test")
@Api("swagger测试接口")
public class TestController {

    @PostMapping("sayHello")
    @ApiOperation("测试方法")
    public R sayHello(@Valid @RequestBody TestSayHelloForm form){
        return R.ok().put("message","Hello Swagger " + "Hi " + form.getName());
    }

    @PostMapping("testAccredit")
    @ApiOperation("授权测试")
    @RequiresPermissions(value = {"ROOT","USER:ADD"},logical = Logical.OR)
    public R testAccredit(){
        return R.ok("已获得授权，调用成功！");
    }

}
